package com.purengage.ipilih;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.TabSpec;

public class RekapTPS extends TabActivity{
private TabHost mTabHost;
	
	private void setupTabHost() {
		mTabHost = (TabHost) findViewById(android.R.id.tabhost);
		mTabHost.setup();
	}
	
	public void onCreate(Bundle savedInstanceState) {
	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_rekaptps);
		
		setupTabHost();
		mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

		setupTab(new TextView(this), "TPS", "TPS.class", R.drawable.rekap_w);
		setupTab(new TextView(this), "Kirim", "KirimTPS.class", R.drawable.truck_w);
		
	}
	
	private void setupTab(final View view, final String tag,
			final String className, final int drawable) {
		View tabview = createTabView(mTabHost.getContext(), tag, drawable);

		Intent intent;
		intent = new Intent().setClass(this, TPS.class);
		if (className.equals("TPS.class")) {
			intent = new Intent().setClass(this, TPS.class);
		}
		if (className.equals("KirimTPS.class")) {
			intent = new Intent().setClass(this, KirimTPS.class);
		}

		TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview)
				.setContent(intent);
		{
		}
		;

		mTabHost.addTab(setContent);
	}

	private static View createTabView(final Context context, final String text, final int drawable) {
		View view = LayoutInflater.from(context)
				.inflate(R.layout.tabs_bg, null);
		TextView tv = (TextView) view.findViewById(R.id.tabsText);
		ImageView iv = (ImageView) view.findViewById(R.id.imgTab);
		tv.setText(text);
		iv.setImageResource(drawable);
		return view;
	}
}
